#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define all(x) (x).begin(),(x).end()
typedef long long ll;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<VI> VVI;

typedef pair<int,int> PII;
typedef vector<PII> VPII;
#define X first
#define Y second
#define mp make_pair

#define two(x) (1<<(x))
#define twoll(x) ((long long)1<<(x))
#define contain(s,x) (((s)&two(x))!=0)
#define containll(s,x) (((s)&twoll(x))!=0)

#define db(a) cout << #a << "=" << a << " "
#define dbn cout << endl
#define sqr(x) (x)*(x)

string STR(int n) { char tmp[20]; sprintf(tmp,"%d",n); return tmp; }
int INT(string s) { return atoi(s.c_str()); }
template <class Ty, class Tx> Ty to(const Tx &x) { Ty y; stringstream ss; ss<<x; ss>>y; return y; }

const int INF = 1000000007;
const double EPS = 1e-10;

char buf[1<<20];
int TC;

int N,M,X[45],Y[45];
double D[45][45];

int getNext(int idx, VI pool) {
	double dist = -1;
	int ret = 0;
	for (int i = 0; i < pool.size(); ++i) {
		double cur = D[pool[i]][idx];
		if (dist == -1 || cur < dist)
			ret = pool[i], dist = cur;
	}
	return ret;
}

int main() {
#define SUBMIT 0
#if !SUBMIT
	freopen("DATA.in", "rt", stdin);
	freopen("DATA.ou", "wt", stdout);
#endif

	gets(buf); TC = atoi(buf);
	
	while (TC--) {
		scanf("%d%d",&N,&M);
		for (int i = 0; i < N; ++i)
			scanf("%d%d",&X[i],&Y[i]);
		for (int i = 0; i < M; ++i)
			scanf("%d%d",&X[i+N],&Y[i+N]);
		for (int i = 0; i < N+M; ++i)
			for (int j = i+1; j < N+M; ++j)
				D[i][j] = D[j][i] = hypot(X[i]-X[j],Y[i]-Y[j]);
		for (int i = 0; i < N+M; ++i)
			D[i][i] = 0;
		
		printf("%.1f\n",0);
	}

	return 0;
}





